<%@page import="com.estore.entity.WebInterface"%>
<%@page import="com.estore.manager.InterfaceManager"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@include file="/common/definition.jsp"%>
<%@ page language="java" import="java.util.*"%>

<%
    WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application);
	InterfaceManager interfaceManager = (InterfaceManager) context.getBean("interface");
	WebInterface webInterface = interfaceManager.getWebInterface();
%>

<html:html>
<tiles:insert beanName="homepage-definition" flush="true">
	<tiles:put name="title"> Trang Chủ </tiles:put>
	<tiles:put name="body" type="string">


		<div class="col-md-12">
			<div class="col-md-12 mainHome">
			<div class="col-md-12 row" style="padding-top: 10px; ">
				<div class="col-md-4" style="padding: 10px; color: #ffffff; background-image:url('img/vienxanh.png');
				background-repeat:repeat-x;">
					<b>SẢN PHẨM MỚI NHẤT</b>
				</div>
				<div class="col-md-2" style="width: 114px; height: 35px; background-image: url('img/duoivien.png');"></div>
			</div>
				<div class="tab-content">
						<!-- START Vùng hiển thị sản phẩm -->
						<div class="row" style="padding: 20px">
							<s:iterator value="list12NewProduct">
								<% if(webInterface.getProductList().equals("type1")){ %>
									<div class="col-md-3">
										<s:a action="clickDetailProduct" cssClass="thumbnail heightThumb">
											<s:if test="mainImgLink == null">
												<img style="height: 150px" width=100%
													src='img/avatar/no_product_img.jpg'>
											</s:if>
											<s:else>
												<img style="height: 150px" width=100%
													src='<s:property value="mainImgLink"/>'>
											</s:else>
											<div class="caption">
												<h5 class="text-center text-success">
													<s:property value="catName" />
													<s:property value="brandName" />
													<s:property value="productName" />
												</h5>
												<p class="text-danger text-right">
													<s:if test="sellingPrice == 0">
														Hiện không có cửa hàng bán sản phẩm
													</s:if>
													<s:elseif test="sellingPrice == null">
														Chưa có cửa hàng bán sản phẩm
													</s:elseif>
													<s:else>
														<s:if test="discount != null">
															Giá bán: <s:property value="sellingPrice"/>000 vnd <br>
															Giá khuyến mãi: <s:property value="discount"/>000 vnd 
															(<s:property value="discountPercent"/> %)
														</s:if>
														<s:else>
															Giá bán: <s:property value="sellingPrice"/>000 vnd
														</s:else>
													</s:else>
												</p>
											</div>
											<s:param name="productID" value="productID" />
										</s:a>
									</div>
								<% }else{ %>
									<div class="col-md-3" style="padding-right: 15px">
										<div class="path_sp text-center" style="padding: 0px; margin-bottom: 15px;">
											<s:a action="clickDetailProduct" title="%{productName}" data-toggle="tooltip">
												<div class="" style="background-color: white;">
													<s:if test="mainImgLink == null">
														<img style="height: 170px" width=90%
															src='img/avatar/no_product_img.jpg'>
													</s:if>
													<s:else>
														<img style="height: 170px" width=90%
															src='<s:property value="mainImgLink"/>'>
													</s:else>
												</div>
												<s:param name="productID" value="productID" />
											</s:a>
											<h5 class="text-center text-success" style="padding-top: 5px">
												<s:a action="detailShopProduct">
													<h5 class="text-center text-success">
														<s:property value="catName" />
														<s:property value="brandName" />
														<s:property value="productName" />
													</h5>
												</s:a>
											</h5>
												<p class="text-danger">
													<s:if test="sellingPrice == 0">
														Hiện không có cửa hàng bán sản phẩm
													</s:if>
													<s:elseif test="sellingPrice == null">
														Chưa có cửa hàng bán sản phẩm
													</s:elseif>
													<s:else>
														<s:if test="discount != null">
															Giá bán: <s:property value="sellingPrice"/>000 vnd <br>
															Giá khuyến mãi: <s:property value="discount"/>000 vnd 
															(<s:property value="discountPercent"/> %)
														</s:if>
														<s:else>
															Giá bán: <s:property value="sellingPrice"/>000 vnd
														</s:else>
													</s:else>
												</p>
										</div>
										
								</div>
								<% } %>
							</s:iterator>
							<!-- END 1 SP -->
						</div>
					</div>
					<!-- div end tab 1 -->
					<div class="col-md-12 row" style="padding-top: 10px; ">
						<div class="col-md-4" style="padding: 10px; color: #ffffff; background-image:url('img/vienxanh.png');
						background-repeat:repeat-x;">
							<b>SẢN PHẨM ĐƯỢC ƯA THÍCH NHẤT</b>
						</div>
						<div class="col-md-2" style="width: 114px; height: 35px; background-image: url('img/duoivien.png');"></div>
					</div>
					<div class="tab-content">
					<div class="row" style="padding: 20px">
						<s:iterator value="list12MostFavoriteProduct">
							<% if(webInterface.getProductList().equals("type1")){ %>
									<div class="col-md-3">
										<s:a action="clickDetailProduct"
											cssClass="thumbnail heightThumb">
											<s:if test="mainImgLink == null">
												<img style="height: 150px" width=100%
													src='img/avatar/no_product_img.jpg'>
											</s:if>
											<s:else>
												<img style="height: 150px" width=100%
													src='<s:property value="mainImgLink"/>'>
											</s:else>
											<div class="caption">
												<h5 class="text-center text-success">
													<s:property value="catName" />
													<s:property value="brandName" />
													<s:property value="productName" />
												</h5>
												<p class="text-danger text-right">
													<s:if test="sellingPrice == 0">
														Hiện không có cửa hàng bán sản phẩm
													</s:if>
													<s:elseif test="sellingPrice == null">
														Chưa có cửa hàng bán sản phẩm
													</s:elseif>
													<s:else>
														<s:if test="discount != null">
															Giá bán: <s:property value="sellingPrice"/>000 vnd <br>
															Giá khuyến mãi: <s:property value="discount"/>000 vnd 
															(<s:property value="discountPercent"/> %)
														</s:if>
														<s:else>
															Giá bán: <s:property value="sellingPrice"/>000 vnd
														</s:else>
													</s:else>
												</p>
											</div>
											<s:param name="productID" value="productID" />
										</s:a>
									</div>
								<% }else{ %>
									<div class="col-md-3" style="padding-right: 15px">
										<div class="path_sp text-center" style="padding: 0px; margin-bottom: 15px;">
											<s:a action="clickDetailProduct" title="%{productName}" data-toggle="tooltip">
												<div class="" style="background-color: white;">
													<s:if test="mainImgLink == null">
														<img style="height: 170px" width=90%
															src='img/avatar/no_product_img.jpg'>
													</s:if>
													<s:else>
														<img style="height: 170px" width=90%
															src='<s:property value="mainImgLink"/>'>
													</s:else>
												</div>
												<s:param name="productID" value="productID" />
											</s:a>
											<h5 class="text-center text-success" style="padding-top: 5px">
												<s:a action="detailShopProduct">
													<h5 class="text-center text-success">
														<s:property value="catName" />
														<s:property value="brandName" />
														<s:property value="productName" />
													</h5>
												</s:a>
											</h5>
												<p class="text-danger">
													<s:if test="sellingPrice == 0">
														Hiện không có cửa hàng bán sản phẩm
													</s:if>
													<s:elseif test="sellingPrice == null">
														Chưa có cửa hàng bán sản phẩm
													</s:elseif>
													<s:else>
														<s:if test="discount != null">
															Giá bán: <s:property value="sellingPrice"/>000 vnd <br>
															Giá khuyến mãi: <s:property value="discount"/>000 vnd 
															(<s:property value="discountPercent"/> %)
														</s:if>
														<s:else>
															Giá bán: <s:property value="sellingPrice"/>000 vnd
														</s:else>
													</s:else>
												</p>
										</div>
										
								</div>
								<% } %>
						</s:iterator>
						</div>
						<!-- END 1 SP -->
					</div>
				</div>
			</div>
	</tiles:put>
</tiles:insert>
</html:html>
